package bjtu.cit.bookshop.controller;

import bjtu.cit.bookshop.common.ErrorCode;
import bjtu.cit.bookshop.entities.Book;
import bjtu.cit.bookshop.entities.Order;
import bjtu.cit.bookshop.entities.User;
import bjtu.cit.bookshop.service.IBookService;
import bjtu.cit.bookshop.service.IOrderService;
import bjtu.cit.bookshop.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/")
public class HelloController extends BaseController {

    @Resource
    private IUserService userService = null;

    @Resource
    private IBookService bookService = null;

    @Resource
    private IOrderService orderService = null;

    @RequestMapping("hello.do")
	public String printWelcome(ModelMap model) {
        Book book = new Book();
        book.setPublisherid(1);
        List<Book> books = bookService.getBookByNotNullField(book);
        Order order = new Order();
        order.setAddress("hahahaAddress");
        model.addAttribute("message", books.size());

        return "hello";
	}
/*
    @RequestMapping("index.do")
    public String index(ModelMap model) {
        //model.addAttribute("isLogin", false);
        model.addAttribute("current", "home");
        model.addAttribute("isLogin", false);
        model.addAttribute("loginName", "Zachary");
        return "index";
    }
*/


    /*
    @ResponseBody
    @RequestMapping("json.do")
    public ErrorCode getJson(ModelMap model) {
        return SUCCESS;
    }
    */
}